<style rel="stylesheet/scss" lang="scss" scoped>
::v-deep .el-step__icon.is-text {
  border: none !important;
  height: 50px;
}

::v-deep .el-step__main {
  padding-top: 11px;
  padding-left: 30px !important
}

.weixinError ::v-deep .el-form-item--small .el-form-item__error {
  width: 350px !important;
}

.dashboard-editor-container {
  padding: 18px 22px 22px 22px;
  background-color: rgb(240, 242, 245);
  margin-bottom: 80px;

  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
}

.form-operator-button {
  background-color: #fff;
  position: fixed;
  width: 100%;
  left: 0px;
  right: 0;
  bottom: 33px;
  height: 64px;
  line-height: 64px;
  text-align: right;
  box-shadow: 0 -1px 2px 0 rgba(0, 0, 0, .05);
  z-index: 10;
}

.form-el-radion {
  line-height: 30px;
  padding: 5px 0px;
  width: 100%;
}

.hex-form-inf {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  cursor: pointer;
  margin-right: 40px;
  position: relative;
  min-height: 33px;
  margin-left: 60px;
  line-height: 33px;

}

.hex-form-inf-content {
  font-size: 14px;
  font-weight: 500;
  display: none;
}

.hex-form-inf .hex-form-inf-content-show {
  padding: 0 4%;
  background-color: gainsboro;
  border-radius: 8px;
}

.hex-form-inf {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  cursor: pointer;
  margin-right: 40px;
  position: relative;
  min-height: 33px;
  margin-left: 60px;
  line-height: 33px;
}

.hex-form-inf-icon {
  font-size: 20px;
  margin-top: 5px;
  position: absolute;
  right: 0px;
}

.form-operator-button {
  background-color: #fff;
  position: fixed;
  width: 100%;
  left: 0px;
  right: 0;
  bottom: 33px;
  height: 64px;
  line-height: 64px;
  text-align: right;
  box-shadow: 0 -1px 2px 0 rgba(0, 0, 0, .05);
  z-index: 10;
}

.form-el-radion {
  line-height: 30px;
  padding: 5px 0px;
  width: 100%;
}

.hex-form-inf {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  cursor: pointer;
  margin-right: 40px;
  position: relative;
  min-height: 33px;
  margin-left: 60px;
  line-height: 33px;
  color: #347DE1
}

.hex-form-inf-content {
  font-size: 14px;
  font-weight: 500;
  display: none;
}

.hex-form-inf .hex-form-inf-content-show {
  padding: 0 4%;
  background-color: #F7F9FA;
  border: 1px solid #347DE1;
  border-radius: 8px;
}

.hex-form-inf {
  display: -webkit-box;
  display: -ms-flexbox;
  display: flex;
  cursor: pointer;
  margin-right: 40px;
  position: relative;
  min-height: 33px;
  margin-left: 60px;
  line-height: 33px;
}

.hex-form-inf-icon {
  font-size: 20px;
  margin-top: 5px;
  position: absolute;
  right: 0px;
}

::v-deep .el-input__inner {
  padding-right: 60px;
}
</style>
<template>
  <div class="dashboard-container">
    <div class="dashboard-editor-container" v-if="showType=='job' && crud.optPageShow.excelPage == false">
      <!--表单-->
      <el-card class="box-card" v-if="crud.optPageShow.listPage">
        <div slot="header" class="clearfix">
          <span>周期作业定义列表</span>
        </div>
        <!--工具栏-->
        <div class="head-container">
          <crudOperation :permission="permission" :moreQueryList="moreQueryList"/>
        </div>
        <!--表格渲染-->
        <el-table ref="table" v-loading="crud.loading" :data="crud.data"
                  :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
                  row-key="id" @select="crud.selectChange" @select-all="crud.selectAllChange"
                  @selection-change="crud.selectionChangeHandler"
                  @filter-change="crud.handleFilterChange"
                  :header-cell-style="{ background: 'rgba(52, 125, 225, 0.1)', color: '#404248' }"
                  @row-dblclick="goTaskInfo" border stripe>
          <el-table-column type="selection" width="55"/>
          <el-table-column v-if="columns.visible('jobCode')" :show-overflow-tooltip="true" label="作业编码" min-width="200"
                           prop="jobCode"/>
          <el-table-column v-if="columns.visible('jobName')" :show-overflow-tooltip="true" label="作业名称" min-width="200"
                           prop="jobName"/>
          <el-table-column v-if="columns.visible('labelName')" :show-overflow-tooltip="true" label="标签名称"
                           prop="labelName"/>
          <el-table-column v-if="columns.visible('jobPeriod')" prop="jobPeriod" label="调度间隔 " min-width="80"
                           :filters="jobPeriodStatusDict" key="jobPeriod"
                           filter-placement="bottom-end" :filter-multiple="false" column-key="jobPeriod">
            <template slot-scope="scope">
              {{ jobPeriodFormatter(scope.row.jobPeriod) }}
            </template>
          </el-table-column>
          <el-table-column v-if="columns.visible('dateExpression')" :show-overflow-tooltip="true" label="日期表达式"
                           prop="dateExpression"/>
          <el-table-column v-if="columns.visible('sortNo')" :show-overflow-tooltip="true" label="优先级" prop="sortNo"/>
          <el-table-column v-if="columns.visible('offsetHour')" :show-overflow-tooltip="true" label="偏移小时"
                           prop="offsetHour"/>
          <el-table-column v-if="columns.visible('jobStatus')" prop="jobStatus" label="状态"
                           min-width="80" key="jobStatus" filter-placement="bottom-end" :filter-multiple="false"
                           column-key="jobStatus">
            <template slot-scope="scope">
              <el-tag size="small" :type="jobStatusFormatterType(scope.row.jobStatus)" style="width:60px;">
                {{ jobStatusFormatter(scope.row) }}
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column v-if="columns.visible('batchTag')" :show-overflow-tooltip="true" label="批次标签"
                           prop="batchTag">
            <template slot-scope="scope">
              <el-tag size="medium" type="success" v-if="scope.row.batchTag!=''&& scope.row.batchTag != null">
                {{ scope.row.batchTag }}
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column v-if="columns.visible('crtTs')" min-width="140" :show-overflow-tooltip="true" label="创建时间"
                           prop="crtTs"/>
        </el-table>
      </el-card>

      <!--新增作业 start-->
      <el-card class="box-card" v-if="crud.optPageShow.addPage" style="padding-bottom: 30px">
        <div slot="header" class="clearfix">
          <div class="el-page-header">
            <div class="el-page-header__left" @click="goListBack">
              <i class="el-icon-back"></i>
              <div class="el-page-header__title">返回</div>
            </div>
            <div class="el-page-header__content" style="font-size: 14px;">{{ crud.status.title }}</div>
          </div>
        </div>
        <el-col :span="4" style="height: 600px;padding: 30px 20px 60px 20px;">
          <el-steps direction="vertical" :active="active">
            <el-step title="作业信息">
              <template slot="icon">
                <img v-if="active>=1" src="@images/active.png" alt="" class="activepng">
                <img v-else src="@images/noactive.png" alt="" class="activepng">
              </template>
            </el-step>
            <el-step title="任务信息">
              <template slot="icon">
                <img v-if="active>=2" src="@images/active.png" alt="" class="activepng">
                <img v-else src="@images/noactive.png" alt="" class="activepng">
              </template>
            </el-step>
            <el-step title="任务列表">
              <template slot="icon">
                <img v-if="active>=3" src="@images/active.png" alt="" class="activepng">
                <img v-else src="@images/noactive.png" alt="" class="activepng">
              </template>
            </el-step>
            <el-step title="任务依赖图">
              <template slot="icon">
                <img v-if="active>=4" src="@images/active.png" alt="" class="activepng">
                <img v-else src="@images/noactive.png" alt="" class="activepng">
              </template>
            </el-step>
          </el-steps>
        </el-col>
        <el-col :span="18" style="padding: 30px;border-left: 1px solid #EBEEF5;min-height: 360px;background:#F7F9FA;">
          <div v-if="active == 0">
            <el-form ref="form" :rules="rules" :model="form" label-position="left" label-width="160px">
              <div>
                <el-row>
                  <el-col :xs="12" :sm="12" :md="12" :lg="14" :xl="12">
                    <el-form-item label="作业编码" prop="jobCode">
                      <el-input type="text" show-word-limit v-if="this.crud.form.pkId === null" v-model="form.jobCode"
                                maxlength="100" placeholder="请输入作业编码"/>
                      <el-input type="text" show-word-limit v-if="this.crud.form.pkId != null" :disabled="true"
                                maxlength="100" placeholder="请输入作业编码" v-model="form.jobCode"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        唯一编码，大写英文字母与数字组成，不能为大小写混合不能多于100个字符串
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="12" :sm="12" :md="12" :lg="14" :xl="12">
                    <el-form-item label="作业名称" prop="jobName">
                      <el-input type="text" show-word-limit v-model="form.jobName" placeholder="请输入作业名称"
                                maxlength="100"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        作业名称不多于100位
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                </el-row>

                <el-row>
                  <el-col :xs="12" :sm="12" :md="12" :lg="14" :xl="12">
                    <el-form-item label="作业标签" prop="labelCodeList">
                      <el-select @remove-tag="aaa" style="width: 100%" value-key="labelCode"
                                 v-model="form.labelCodeList" filterable multiple placeholder="请选择">
                        <el-option
                          v-for="item in labelList"
                          :key="item.labelCode"
                          :label="item.labelName"
                          :disabled="item.disabled"
                          :value="item.labelCode">
                          <span style="float: left">{{ item.labelCode }} | {{ item.labelCode }}</span>
                          <span style="float: right; color: #8492a6; font-size: 13px">{{
                              item.labelLevel == '1' ? '系统级' : '平台级'
                            }}</span>
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        作业标签
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                </el-row>

                <el-row>
                  <el-col :xs="12" :sm="12" :md="12" :lg="14" :xl="12">
                    <el-form-item label="是否单次作业" prop="isSingleJob">
                      <el-switch v-model="form.isSingleJob" active-value="1" inactive-value="0"
                                 @change="isSingleJobChange">
                      </el-switch>
                    </el-form-item>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        该作业定义是否只生成一次作业实例，默认否
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                </el-row>
                <el-collapse-transition>
                  <el-row v-if="form.isSingleJob == 1">
                    <el-col :span="12">
                      <el-form-item label="业务日期" prop="dateExpression">
                        <el-date-picker style="width: 201px" v-model="form.dateExpression" value-format="yyyyMMdd"
                                        type="date"
                                        :picker-options="bizDatePickerOptions">
                        </el-date-picker>
                      </el-form-item>
                    </el-col>
                    <el-col :span="11" class="data_from_el-col">
                      <div class="hex-form-inf">
                        <div class="hex-form-inf-content">
                          单次作业生成实例的业务日期。
                        </div>
                        <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                      </div>
                    </el-col>
                  </el-row>
                </el-collapse-transition>
                <el-row v-if="form.isSingleJob !=1">
                  <el-col :xs="12" :sm="12" :md="12" :lg="14" :xl="12">
                    <el-form-item label="调度间隔" prop="jobPeriod">
                      <el-select v-model="form.jobPeriod" filterable placeholder="请选择" @change="jobPeriodChange">
                        <el-option v-for="item in this.dict.cycle_job_period" :key="item.value" :label="item.label"
                                   :value="item.value">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        频率（D:日 W:周 M:月 Q:季度 X:旬 Y:年 O:自定义）
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                </el-row>
                <el-row v-if="form.isSingleJob !=1">
                  <el-col :xs="12" :sm="12" :md="12" :lg="14" :xl="12">
                    <el-form-item label="日期表达式" prop="dateExpression">
                      <el-input v-if="form.jobPeriod =='D'" v-model="form.dateExpression" :disabled="true"/>
                      <el-input-number v-if="form.jobPeriod =='W'" v-model="form.dateExpression" :min="0"
                                       :max="6"></el-input-number>
                      <el-input-number v-if="form.jobPeriod =='X'" v-model="form.dateExpression" :min="-30"
                                       :max="30"></el-input-number>
                      <el-input-number v-if="form.jobPeriod =='M'" v-model="form.dateExpression" :min="-30"
                                       :max="30"></el-input-number>
                      <el-input-number v-if="form.jobPeriod =='Q'" v-model="form.dateExpression" :min="-30"
                                       :max="30"></el-input-number>
                      <el-input-number v-if="form.jobPeriod =='Y'" v-model="form.dateExpression" :min="-365"
                                       :max="365"></el-input-number>
                      <el-input v-if="form.jobPeriod =='O'" v-model="form.dateExpression" placeholder="* * *"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col" v-show="form.jobPeriod !== 'M' && form.jobPeriod !== 'W'">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        作业的周期开始时间表达式
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col" v-show="form.jobPeriod === 'M'">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        作业的周期时间表达式，-1:月底 0和1:月初
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col" v-show="form.jobPeriod === 'W'">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        作业的周期时间表达式，0:周日
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="12" :sm="12" :md="12" :lg="14" :xl="12">
                    <el-form-item label="优先级" prop="sortNo">
                      <el-select v-model="form.sortNo" filterable placeholder="请选择">
                        <el-option v-for="item in levelData" :key="item.value" :label="item.label" :value="item.value">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        优先级数值越大，优先执行
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                </el-row>
                <el-row v-if="form.isSingleJob != 1">
                  <el-col :xs="12" :sm="12" :md="12" :lg="14" :xl="12">
                    <el-form-item label="是否工作日执行" prop="isWorkRun">
                      <el-switch v-model="form.isWorkRun" active-value="1" inactive-value="0">
                      </el-switch>
                    </el-form-item>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        是否根据设置作业工作日执行
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="12" :sm="12" :md="12" :lg="14" :xl="12">
                    <el-form-item label="偏移小时" prop="offsetHour">
                      <el-input-number v-model="form.offsetHour" :min="0" :max="60"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        允许作业定义晚生成作业实例的时间
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                </el-row>
                <el-row v-if="form.isSingleJob != 1">
                  <el-col :xs="12" :sm="12" :md="12" :lg="14" :xl="12">
                    <el-form-item label="设置生效日期" prop="isValidDate">
                      <el-switch v-model="form.isValidDate" active-value="1" inactive-value="2">
                      </el-switch>
                    </el-form-item>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        是否设置作业的有效期限
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                </el-row>
                <el-collapse-transition>
                  <el-row v-if="form.isValidDate==1&&form.isSingleJob != 1">
                    <el-col :xs="12" :sm="12" :md="12" :lg="14" :xl="12">
                      <el-form-item label="日期区间" prop="dateRange">
                        <el-date-picker v-model="form.dateRange" type="daterange" align="right" unlink-panels
                                        range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"
                                        value-format="yyyy-MM-dd">
                        </el-date-picker>
                      </el-form-item>
                    </el-col>
                    <el-col :span="9" class="data_from_el-col">
                      <div class="hex-form-inf">
                        <div class="hex-form-inf-content">
                          作业的有效期限。
                        </div>
                        <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                      </div>
                    </el-col>
                  </el-row>
                </el-collapse-transition>
                <el-row>
                  <el-col :xs="12" :sm="12" :md="12" :lg="14" :xl="12">
                    <el-form-item label="指定节点名称" prop="appointAgentCode">
                      <el-select v-model="form.appointAgentCode" filterable clearable placeholder="请选择">
                        <el-option v-for="item in agentCodeOption" :key="item.agentCode" :label="item.agentName"
                                   :value="item.agentCode">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        指定作业在哪个节点服务器上执行。
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="12" :sm="12" :md="12" :lg="14" :xl="12">
                    <el-form-item label="描述" prop="jobDesc">
                      <el-input type="textarea" :autosize="{ minRows: 4, maxRows: 5}" placeholder="请输入内容"
                                v-model="form.jobDesc" maxlength="60"
                                show-word-limit>
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        作业的描述，不可超过60个字
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                </el-row>
                <div class="form-operator-button" style="text-align:center">
                  <!--<el-button @click="channel()"type="primary"  style="margin-right: 2%;">取消</el-button>-->
                  <el-button type="primary" :loading="loadStatus" v-if="this.crud.status.edit !=1" @click="nextSetp1()">
                    下一步
                  </el-button>
                </div>
              </div>
            </el-form>
          </div>
          <div v-if="active == 1">
            <el-form ref="taskForm" :inline="true" :rules="taskRules" :model="taskForm" size="small" label-width="120px"
                     label-position="left">
              <div>
                <el-row>
                  <el-col :xs="12" :sm="12" :md="12" :lg="14" :xl="12" class="weixinError">
                    <el-form-item label="任务编码" prop="taskCode" key="taskCode">
                      <el-input type="text" show-word-limit v-if="taskForm.pkId === null" v-model="taskForm.taskCode"
                                maxlength="100" style="width:200%;"/>
                      <el-input type="text" show-word-limit v-if="taskForm.pkId != null" :disabled="true"
                                v-model="taskForm.taskCode" maxlength="100" style="width:200%;"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        唯一编码，任务编号不多于100位
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="12" :sm="12" :md="12" :lg="14" :xl="12">
                    <el-form-item label="任务名称" prop="taskName" key="taskName">
                      <el-input type="text" show-word-limit v-model="taskForm.taskName" style="width:200%;"
                                maxlength="100"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        任务的名称，任务名称不多于100位
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="12" :sm="12" :md="12" :lg="14" :xl="12">
                    <el-form-item label="脚本路径" prop="shellPath" key="shellPath">
                      <el-input v-model="taskForm.shellPath" style="width:200%;"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        脚本的执行路径，如/***/***/**.sh
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="12" :sm="12" :md="12" :lg="14" :xl="12">
                    <el-form-item label="外部参数" prop="extParam">
                      <el-input v-model="taskForm.extParam" style="width:200%;"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        脚本执行参数
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="12" :sm="12" :md="12" :lg="14" :xl="12">
                    <el-form-item label="优先级" prop="priorityLevel">
                      <el-select v-model="taskForm.priorityLevel" filterable placeholder="请选择" style="width: 350px">
                        <el-option v-for="item in levelData" :key="item.value" :label="item.label" :value="item.value">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        优先级数值越大，优先执行
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="12" :sm="12" :md="12" :lg="14" :xl="12">
                    <el-form-item label="资源数" prop="resNum" :rules="[{
              required: true,
              message: '请输入资源数',
              trigger: 'blur'
            }]">
                      <el-input-number v-model="taskForm.resNum" :min="1" :max="1000"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        任务所占资源数，默认为5，特殊大作业增大数值
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="12" :sm="12" :md="12" :lg="14" :xl="12">
                    <el-form-item label="指定节点名称" prop="appointAgentCode">
                      <el-select v-model="taskForm.appointAgentCode" filterable clearable placeholder="请选择"
                                 style="width: 350px">
                        <el-option v-for="item in agentCodeOption" :key="item.agentCode" :label="item.agentName"
                                   :value="item.agentCode">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        指定任务在哪个节点服务器上执行
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="12" :sm="12" :md="12" :lg="14" :xl="12">
                    <el-form-item label="依赖作业" prop="dependJobCodeList">
                      <el-select @change="$forceUpdate()" v-model="taskForm.dependJobCodeList" filterable multiple
                                 placeholder="请点击更多"
                                 style="width:400px">
                      </el-select>
                    </el-form-item>
                    <el-button @click="moreDepend()" type="primary" style="margin-left: 10px;">
                      更多
                    </el-button>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        该任务的上游依赖作业
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="12" :sm="12" :md="12" :lg="14" :xl="12">
                    <el-form-item label="依赖任务" prop="dependTaskCodeList">
                      <el-select @change="$forceUpdate()" v-model="taskForm.dependTaskCodeList" filterable multiple
                                 placeholder="请点击更多"
                                 style="width: 400px">
                      </el-select>
                    </el-form-item>
                    <el-button @click="moreTaskDepend()" type="primary" style="margin-left: 10px;">
                      更多
                    </el-button>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        该任务的上游依赖任务
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                </el-row>

                <el-row>
                  <el-col :xs="12" :sm="12" :md="12" :lg="14" :xl="12">
                    <el-form-item label="允许出错次数" prop="allowErrCount" :rules="[{
              required: true,
              message: '请输入出错次数',
              trigger: 'blur'
            }]">
                      <el-input-number v-model="taskForm.allowErrCount" :min="0" :max="100"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        允许发送节点失败次数
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="12" :sm="12" :md="12" :lg="14" :xl="12">
                    <el-form-item label="预计执行时长(秒)" prop="planExecDuration" :rules="[{
              required: true,
              message: '请输入预计执行时长(秒)',
              trigger: 'blur',

            }]">
                      <el-input-number v-model="taskForm.planExecDuration" :min="0" :max="100000"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        预估任务的执行时间
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="12" :sm="12" :md="12" :lg="14" :xl="12">
                    <el-form-item label="超时时长(秒)" prop="overPlanDuration" :rules="[{
              required: true,
              message: '请输入超时时长(秒)',
              trigger: 'blur'
            }]">
                      <el-input-number v-model="taskForm.overPlanDuration" :min="0" :max="100000"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        允许任务超时最大时长
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :xs="12" :sm="12" :md="12" :lg="14" :xl="12">
                    <el-form-item label="出错间隔时长(秒)" prop="errDifferDuration" :rules="[{
              required: true,
              message: '请输入出错间隔时长(秒)',
              trigger: 'blur'
            }]">
                      <el-input-number v-model="taskForm.errDifferDuration" :min="0" :max="100000"/>
                    </el-form-item>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        任务发送失败，重新发送时间间隔
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                </el-row>

                <el-row>
                  <el-col :xs="12" :sm="12" :md="12" :lg="14" :xl="12">
                    <el-form-item label="任务备注" prop="taskRemark">
                      <el-input type="textarea" v-model="taskForm.taskRemark" style="width:300px;"></el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="9" class="data_from_el-col">
                    <div class="hex-form-inf">
                      <div class="hex-form-inf-content">
                        任务的详情备注信息
                      </div>
                      <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                    </div>
                  </el-col>
                </el-row>

                <div class="form-operator-button" style="text-align:center">
                  <el-button type="primary" @click="lastSetp">上一步</el-button>
                  <el-button type="primary" :loading="loadTaskStatus" @click="nextSetp2('taskForm')">下一步</el-button>
                </div>
              </div>
            </el-form>
          </div>
          <div v-if="active == 2">
            <el-table ref="taskTable" :data="taskDataList"
                      :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
                      row-key="id" @select="crud.selectChange" @select-all="crud.selectAllChange"
                      @selection-change="crud.selectionChangeHandler"
                      @filter-change="crud.handleFilterChange" @row-click="taskdetail" id="taskDataList"
                      :header-cell-style="{ background: 'rgba(52, 125, 225, 0.1)', color: '#404248' }"
                      style="width: 100%;margin-bottom: 30px">
              <el-table-column fixed v-if="taskCols.visible('taskCode')" width="120" prop="taskCode"
                               :show-overflow-tooltip="true" label="任务编码"/>
              <el-table-column fixed v-if="taskCols.visible('taskName')" width="200" prop="taskName"
                               :show-overflow-tooltip="true" label="任务名称">
              </el-table-column>
              <el-table-column v-if="taskCols.visible('shellPath')" width="200" prop="shellPath"
                               :show-overflow-tooltip="true"
                               label="脚本信息">
              </el-table-column>
              <el-table-column v-if="taskCols.visible('extParam')" width="100" prop="extParam"
                               :show-overflow-tooltip="true"
                               label="外部参数">
              </el-table-column>
              <el-table-column v-if="taskCols.visible('resNum')" width="60" prop="resNum" :show-overflow-tooltip="true"
                               label="资源数">
              </el-table-column>
              <el-table-column v-if="columns.visible('dependJob')" width="100" prop="dependJob" label="依赖信息">
                <template slot-scope="scope">
                  <el-popover trigger="hover" placement="top-start">
                    <div>
                      <p>依赖作业：{{ scope.row.dependJobName }}</p>
                      <p>依赖任务：{{ scope.row.dependTaskName }}</p>
                    </div>
                    <div slot="reference" class="name-wrapper">
                      <el-tag size="medium">依赖信息</el-tag>
                    </div>
                  </el-popover>
                </template>
              </el-table-column>
              <el-table-column v-if="taskCols.visible('priorityLevel')" width="60" prop="priorityLevel" label="优先级">
              </el-table-column>
              <el-table-column v-if="taskCols.visible('isOrder')" width="80" prop="isOrder" label="顺序执行">
                <template slot-scope="scope">
                  <el-tag v-if="scope.row.isOrder == 1" type="success">是</el-tag>
                  <el-tag v-if="scope.row.isOrder == 2" type="info">否</el-tag>
                </template>
              </el-table-column>
              <el-table-column v-if="taskCols.visible('isEndTask')" width="80" prop="isEndTask" label="结束任务">
                <template slot-scope="scope">
                  <el-tag v-if="scope.row.isEndTask == 1" type="success">是</el-tag>
                  <el-tag v-if="scope.row.isEndTask == 2" type="info">否</el-tag>
                </template>
              </el-table-column>
              <el-table-column v-if="taskCols.visible('allowErrCount')" width="100" prop="allowErrCount" label="允许出错次数">
              </el-table-column>
              <el-table-column v-if="taskCols.visible('planExecDuration')" width="100" prop="planExecDuration"
                               label="预计执行时长(秒)">
              </el-table-column>
              <el-table-column v-if="taskCols.visible('overPlanDuration')" width="100" prop="overPlanDuration"
                               label="超时时长(秒)">
              </el-table-column>
              <el-table-column v-if="taskCols.visible('errDifferDuration')" width="100" prop="errDifferDuration"
                               label="出错间隔时长(秒)">
              </el-table-column>
              <el-table-column label="操作" fixed="right" width="140">
                <template slot-scope="scope">
                  <el-popover placement="top" width="180" trigger="manual">
                    <el-button slot="reference" icon="el-icon-edit" size="mini" @click="editTask(scope.row)"/>
                    <el-button slot="reference" icon="el-icon-delete" size="mini" @click="deleteTask(scope.row)"/>
                  </el-popover>
                </template>
              </el-table-column>
            </el-table>
            <el-row>
              <div class="form-operator-button" style="text-align:center">
                <el-button type="primary" @click="lastSetp">继续添加</el-button>
                <el-button type="primary" @click="nextSetp()">下一步</el-button>
              </div>
            </el-row>

          </div>
          <div v-if="active == 3">
            <taskDepend :jobCode="jobCode" :bizDate="bizDate" :type="dependTaskType"/>
            <div class="form-operator-button" style="text-align:center">
              <el-button type="primary" @click="lastSetp3">上一步</el-button>
              <el-button type="primary" @click="finish()">完成</el-button>
            </div>
          </div>
        </el-col>
      </el-card>
      <!--新增作业 end-->
    </div>

    <!-- 作业详情 start -->
    <div class="dashboard-editor-container" v-if="showType == 'task' && crud.optPageShow.excelPage == false">
      <el-card class="box-card" style="padding-bottom: 30px">
        <div slot="header" class="clearfix">
          <div class="el-page-header">
            <div class="el-page-header__left" @click="goBack">
              <i class="el-icon-back"></i>
              <div class="el-page-header__title">返回</div>
            </div>
            <div class="el-page-header__content">周期作业详情</div>
          </div>
        </div>
        <div class="task-infor">
          <el-tabs v-model="activeName" @tab-click="handleClick">
            <el-tab-pane label="任务列表" name="first">
              <el-col :span="15" style="padding-right: 10px">
                <div class="crud-opts">
                  <span class="crud-flex">
                    <!--左侧插槽-->
                    <slot name="left"/>
                    <img class="img" src="@images/update.png" alt="" @click="doReply()">

                    <!--更多操作-->
                    <el-popover v-if="checkPermission(['appJobDef:edit','appJobDef:del'])" placement="bottom"
                                width="100" style="height:30px" trigger="click">
                      <img class="img" slot="reference" src="@images/more.png" alt="">
                      <div>
                        <el-row v-if="checkPermission(['appJobDef:del'])">
                          <el-button :disabled="crud.selections.length == 0" type="text" :loading="crud.delAllLoading"
                                     @click="toDeleteTask(crud.selections)">删除</el-button>
                        </el-row>
                        <el-row v-if="checkPermission(['appJobDef:edit'])">
                          <el-button :disabled="crud.selections.length == 0" type="text" :loading="crud.delAllLoading"
                                     @click="updateTaskInf(crud.selections,'isOrder')">修改是否顺序执行</el-button>
                        </el-row>
                        <el-row v-if="checkPermission(['appJobDef:edit'])">
                          <el-button :disabled="crud.selections.length == 0" type="text" :loading="crud.delAllLoading"
                                     @click="updateTaskInf(crud.selections,'resNum')">修改资源数</el-button>
                        </el-row>
                        <el-row v-if="checkPermission(['appJobDef:edit'])">
                          <el-button :disabled="crud.selections.length == 0" type="text" :loading="crud.delAllLoading"
                                     @click="updateTaskInf(crud.selections,'priorityLevel')">修改优先级</el-button>
                        </el-row>
                        <el-row v-if="checkPermission(['appJobDef:edit'])">
                          <el-button :disabled="crud.selections.length == 0" type="text" :loading="crud.delAllLoading"
                                     @click="updateTaskInf(crud.selections,'allowErrCount')">修改允许出错次数</el-button>
                        </el-row>
                        <el-row v-if="checkPermission(['appJobDef:edit'])">
                          <el-button :disabled="crud.selections.length == 0" type="text" :loading="crud.delAllLoading"
                                     @click="updateTaskInf(crud.selections,'errDifferDuration')">修改出错间隔时长</el-button>
                        </el-row>
                      </div>
                    </el-popover>
                    <!--右侧-->
                    <slot name="right"/>
                  </span>
                </div>
                <el-table ref="taskTable" :data="taskDataList"
                          :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
                          row-key="id" @select="crud.selectChange" @select-all="crud.selectAllChange"
                          @selection-change="crud.selectionChangeHandler"
                          @filter-change="crud.handleFilterChange" @row-click="taskdetail"
                          :header-cell-style="{ background: 'rgba(52, 125, 225, 0.1)', color: '#404248' }"
                          style="width: 100%;margin-bottom: 30px;" border stripe>
                  <el-table-column type="selection" width="55"/>
                  <el-table-column v-if="taskCols.visible('taskCode')" width="157" prop="taskCode"
                                   :show-overflow-tooltip="true" label="任务编号"/>
                  <el-table-column v-if="taskCols.visible('taskName')" width="160" prop="taskName"
                                   :show-overflow-tooltip="true" label="任务名称">
                  </el-table-column>
                  <el-table-column v-if="taskCols.visible('shellPath')" width="232" prop="shellPath"
                                   :show-overflow-tooltip="true" label="脚本路径">
                  </el-table-column>
                  <el-table-column v-if="taskCols.visible('extParam')" width="200" prop="extParam"
                                   :show-overflow-tooltip="true" label="外部参数">
                  </el-table-column>
                  <el-table-column v-if="taskCols.visible('priorityLevel')" width="87" prop="priorityLevel" label="优先级">
                  </el-table-column>
                  <el-table-column v-if="taskCols.visible('resNum')" prop="resNum" label="资源数" width="109">
                  </el-table-column>
                  <el-table-column v-if="columns.visible('isOrder')" prop="isOrder" label="是否顺序执行" width="120"
                                   align="center">
                    <template slot-scope="scope">
                      <el-tag v-if="scope.row.isOrder == 1" type="success">是</el-tag>
                      <el-tag v-if="scope.row.isOrder == 2" type="info">否</el-tag>
                    </template>
                  </el-table-column>
                </el-table>
              </el-col>
              <el-col :span="9" style="padding-left: 10px;border-left: 1px solid #e4e7ed;" class="weixinError">
                <el-form ref="taskForm" :inline="true" :rules="taskRules" :model="taskForm" size="small"
                         label-position="left"
                         label-width="160px" style="padding-left: 20px">
                  <el-row>
                    <el-form-item label="任务编码" prop="taskCode" key="taskCode">
                      <el-input style="width: 300px" type="text" show-word-limit v-if="taskForm.pkId == null"
                                maxlength="100" v-model="taskForm.taskCode"/>
                      <el-input style="width: 300px" type="text" show-word-limit v-if="taskForm.pkId != null"
                                maxlength="100" :disabled="true" v-model="taskForm.taskCode"/>
                    </el-form-item>
                  </el-row>
                  <el-row>
                    <el-form-item label="任务名称" prop="taskName" key="taskName">
                      <el-input style="width: 300px" type="text" show-word-limit v-model="taskForm.taskName"
                                maxlength="100"/>
                    </el-form-item>
                  </el-row>
                  <el-row>
                    <el-form-item label="脚本路径" prop="shellPath" key="shellPath">
                      <el-input style="width: 300px" v-model="taskForm.shellPath"/>
                    </el-form-item>
                  </el-row>
                  <el-row>
                    <el-form-item label="外部参数">
                      <el-input style="width: 300px" v-model="taskForm.extParam"/>
                    </el-form-item>
                  </el-row>
                  <el-row>
                    <el-form-item label="依赖作业" prop="dependJobCodeList">
                      <el-select @change="$forceUpdate()" v-model="taskForm.dependJobCodeList" filterable multiple
                                 placeholder="请点击更多"
                                 style="width: 300px">

                      </el-select>
                    </el-form-item>
                    <el-button @click="moreDepend()" type="primary" style="margin-left: 10px;">
                      更多
                    </el-button>
                  </el-row>
                  <el-row>
                    <el-form-item label="依赖任务" prop="dependTaskCodeList">
                      <el-select @change="$forceUpdate()" v-model="taskForm.dependTaskCodeList" filterable multiple
                                 placeholder="请点击更多"
                                 style="width: 300px">
                      </el-select>
                    </el-form-item>
                    <el-button @click="moreTaskDepend()" type="primary" style="margin-left: 10px;">
                      更多
                    </el-button>
                  </el-row>

                  <el-row>
                    <el-form-item label="指定节点名称" prop="appointAgentCode">
                      <el-select v-model="taskForm.appointAgentCode" filterable clearable placeholder="请选择"
                                 style="width: 300px">
                        <el-option v-for="item in agentCodeOption" :key="item.agentCode" :label="item.agentName"
                                   :value="item.agentCode">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-row>
                  <el-row>
                    <el-form-item label="优先级">
                      <el-select v-model="taskForm.priorityLevel" filterable placeholder="请选择" style="width: 300px">
                        <el-option v-for="item in levelData" :key="item.value" :label="item.label" :value="item.value">
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-row>
                  <el-row>
                    <el-form-item label="资源数">
                      <el-input-number v-model="taskForm.resNum" :min="1" :max="1000"/>
                    </el-form-item>
                  </el-row>
                  <el-row>
                    <el-form-item label="允许错误次数">
                      <el-input-number v-model="taskForm.allowErrCount" :min="0" :max="100"/>
                    </el-form-item>
                  </el-row>
                  <!--<el-row>
                    <el-form-item label="是否结束任务">
                      <el-switch v-model="taskForm.isEndTask" active-value="1" inactive-value="2"></el-switch>
                    </el-form-item>
                  </el-row>-->
                  <el-row>
                    <el-form-item label="是否顺序执行">
                      <el-switch v-model="taskForm.isOrder" active-value="1" inactive-value="2"></el-switch>
                    </el-form-item>
                  </el-row>
                  <el-row>
                    <el-form-item label="预计执行时长(秒)" prop="planExecDuration">
                      <el-input-number v-model="taskForm.planExecDuration" :min="0"/>
                    </el-form-item>
                  </el-row>
                  <el-row>
                    <el-form-item label="超时时长(秒)" prop="overPlanDuration">
                      <el-input-number v-model="taskForm.overPlanDuration" :min="0"/>
                    </el-form-item>
                  </el-row>
                  <el-row>
                    <el-form-item label="出错间隔时长(秒)" prop="errDifferDuration">
                      <el-input-number v-model="taskForm.errDifferDuration" :min="0"/>
                    </el-form-item>
                  </el-row>
                  <el-row v-if="checkPermission(['appJobDef:add', 'appJobDef:edit'])"
                          style="text-align: right;margin-right: 80px">
                    <el-button @click="resetJobForm">重置</el-button>
                    <el-button type="primary" @click="saveTaskDef">保存</el-button>
                  </el-row>
                </el-form>
              </el-col>
            </el-tab-pane>
            <el-tab-pane label="作业详情" name="second">
              <span slot="label">作业详情</span>
              <el-form ref="jobForm" :inline="true" label-position="left" :model="jobForm" :rules="rules"
                       label-width="240px">
                <el-col :span="24" style="padding: 30px;min-height: 360px">
                  <div>
                    <el-row>
                      <el-col :span="15">
                        <el-form-item label="作业编码" prop="jobCode">
                          <el-input v-model="jobForm.jobCode" type="text" show-word-limit style="width: 500px"
                                    :disabled="true" maxlength="100"/>
                        </el-form-item>
                      </el-col>
                      <el-col :span="9" class="data_from_el-col">
                        <div class="hex-form-inf">
                          <div class="hex-form-inf-content">
                            唯一编码，大写英文字母与数字组成，不能为大小写混合不能多于100个字符串
                          </div>
                          <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                        </div>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col :span="15">
                        <el-form-item label="作业名称" prop="jobName">
                          <el-input v-model="jobForm.jobName" type="text" show-word-limit maxlength="100"
                                    style="width: 500px"/>
                        </el-form-item>
                      </el-col>
                      <el-col :span="9" class="data_from_el-col">
                        <div class="hex-form-inf">
                          <div class="hex-form-inf-content">
                            作业的名称,作业的名称不得多于100位
                          </div>
                          <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                        </div>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col :span="15">
                        <el-form-item label="作业标签" prop="labelCodeList">
                          <el-select @remove-tag="bbb" style="width: 100%" value-key="labelCode"
                                     v-model="jobForm.labelCodeList" filterable multiple placeholder="请选择">
                            <el-option
                              v-for="item in labelList1"
                              :key="item.labelCode"
                              :label="item.labelName"
                              :disabled="item.disabled"
                              :value="item.labelCode">
                              <span style="float: left">{{ item.labelCode }} | {{ item.labelCode }}</span>
                              <span style="float: right; color: #8492a6; font-size: 13px">{{
                                  item.labelLevel == '1' ? '系统级' : '平台级'
                                }}</span>
                            </el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="9" class="data_from_el-col">
                        <div class="hex-form-inf">
                          <div class="hex-form-inf-content">
                            标签
                          </div>
                          <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                        </div>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col :span="15">
                        <el-form-item label="是否单次作业" prop="isSingleJob">
                          <el-switch v-model="jobForm.isSingleJob" @change="editIsSingleJobChange" active-value="1"
                                     inactive-value="0">
                          </el-switch>
                        </el-form-item>
                      </el-col>
                      <el-col :span="9" class="data_from_el-col">
                        <div class="hex-form-inf">
                          <div class="hex-form-inf-content">
                            该作业定义是否只生成一次作业实例，默认否
                          </div>
                          <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                        </div>
                      </el-col>
                    </el-row>
                    <el-collapse-transition>
                      <el-row v-if="jobForm.isSingleJob == 1">
                        <el-col :span="15">
                          <el-form-item label="业务日期" prop="dateExpression">
                            <el-date-picker style="width: 201px" v-model="jobForm.dateExpression"
                                            value-format="yyyyMMdd"
                                            type="date" :picker-options="bizDatePickerOptions">
                            </el-date-picker>
                          </el-form-item>
                        </el-col>
                        <el-col :span="9" class="data_from_el-col">
                          <div class="hex-form-inf">
                            <div class="hex-form-inf-content">
                              单次作业生成实例的业务日期。
                            </div>
                            <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                          </div>
                        </el-col>
                      </el-row>
                    </el-collapse-transition>
                    <el-row v-if="jobForm.isSingleJob !=1">
                      <el-col :span="15">
                        <el-form-item label="调度间隔" prop="jobPeriod">
                          <el-select :disabled="jobForm.isSingleJob == 1" v-model="jobForm.jobPeriod" filterable
                                     style="width: 500px"
                                     @change="jobPeriodChange">
                            <el-option v-for="item in this.dict.cycle_job_period" :key="item.value" :label="item.label"
                                       :value="item.value">
                            </el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="9" class="data_from_el-col">
                        <div class="hex-form-inf">
                          <div class="hex-form-inf-content">
                            频率（D:日 W:周 M:月 Q:季度 X:旬 Y:年 O:自定义）
                          </div>
                          <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                        </div>
                      </el-col>
                    </el-row>
                    <el-row v-if="jobForm.isSingleJob !=1">
                      <el-col :span="15">
                        <el-form-item label="日期表达式" prop="dateExpression" style="width:186%">
                          <el-input style="width: 500px" v-if="jobForm.jobPeriod =='D'" v-model="jobForm.dateExpression"
                                    :disabled="true"/>
                          <el-input-number style="width: 260px" v-if="jobForm.jobPeriod =='W'"
                                           v-model="jobForm.dateExpression"
                                           :min="0" :max="6"></el-input-number>
                          <el-input-number style="width: 260px" v-if="jobForm.jobPeriod =='X'"
                                           v-model="jobForm.dateExpression"
                                           :min="-30" :max="30"></el-input-number>
                          <el-input-number style="width: 260px" v-if="jobForm.jobPeriod =='M'"
                                           v-model="jobForm.dateExpression"
                                           :min="-30" :max="30"></el-input-number>
                          <el-input-number style="width: 260px" v-if="jobForm.jobPeriod =='Q'"
                                           v-model="jobForm.dateExpression"
                                           :min="-30" :max="30"></el-input-number>
                          <el-input-number style="width: 260px" v-if="jobForm.jobPeriod =='Y'"
                                           v-model="jobForm.dateExpression"
                                           :min="-365" :max="365"></el-input-number>
                          <el-input style="width: 500px" v-if="jobForm.jobPeriod =='O'"
                                    :disabled="jobForm.isSingleJob == 1" v-model="jobForm.dateExpression"
                                    placeholder="* * *"/>
                        </el-form-item>
                      </el-col>
                      <el-col :span="9" class="data_from_el-col"
                              v-show="jobForm.jobPeriod !== 'M' && jobForm.jobPeriod !== 'W'">
                        <div class="hex-form-inf">
                          <div class="hex-form-inf-content">
                            作业的周期开始时间表达式
                          </div>
                          <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                        </div>
                      </el-col>
                      <el-col :span="9" class="data_from_el-col" v-show="jobForm.jobPeriod === 'M'">
                        <div class="hex-form-inf">
                          <div class="hex-form-inf-content">
                            作业的周期时间表达式，-1:月底 0和1:月初
                          </div>
                          <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                        </div>
                      </el-col>
                      <el-col :span="9" class="data_from_el-col" v-show="jobForm.jobPeriod === 'W'">
                        <div class="hex-form-inf">
                          <div class="hex-form-inf-content">
                            作业的周期时间表达式，0:周日
                          </div>
                          <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                        </div>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col :span="15">
                        <el-form-item label="优先级" prop="sortNo">
                          <el-select v-model="jobForm.sortNo" filterable placeholder="请选择" style="width: 500px">
                            <el-option v-for="item in levelData" :key="item.value" :label="item.label"
                                       :value="item.value">
                            </el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="9" class="data_from_el-col">
                        <div class="hex-form-inf">
                          <div class="hex-form-inf-content">
                            优先级数值越大，优先执行
                          </div>
                          <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                        </div>
                      </el-col>
                    </el-row>
                    <el-row v-if="jobForm.isSingleJob != 1">
                      <el-col :span="15">
                        <el-form-item label="是否工作日执行" prop="isWorkRun">
                          <el-switch v-model="jobForm.isWorkRun" active-value="1" inactive-value="0">
                          </el-switch>
                        </el-form-item>
                      </el-col>
                      <el-col :span="9" class="data_from_el-col">
                        <div class="hex-form-inf">
                          <div class="hex-form-inf-content">
                            是否根据设置作业工作日执行
                          </div>
                          <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                        </div>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col :span="15">
                        <el-form-item label="偏移小时" prop="offsetHour">
                          <el-input-number v-model="jobForm.offsetHour" :min="0" :max="59" style="width: 260px"/>
                        </el-form-item>
                      </el-col>
                      <el-col :span="9" class="data_from_el-col">
                        <div class="hex-form-inf">
                          <div class="hex-form-inf-content">
                            允许作业定义晚生成作业实例的时间
                          </div>
                          <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                        </div>
                      </el-col>
                    </el-row>
                    <el-row v-if="jobForm.isSingleJob != 1">
                      <el-col :span="15">
                        <el-form-item label="设置生效日期" prop="isValidDate">
                          <el-switch v-model="jobForm.isValidDate" active-value="1" inactive-value="2">
                          </el-switch>
                        </el-form-item>
                      </el-col>
                      <el-col :span="9" class="data_from_el-col">
                        <div class="hex-form-inf">
                          <div class="hex-form-inf-content">
                            是否设置作业的有效期限
                          </div>
                          <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                        </div>
                      </el-col>
                    </el-row>
                    <el-collapse-transition>
                      <el-row v-if="jobForm.isValidDate == 1&&jobForm.isSingleJob != 1">
                        <el-col :span="15">
                          <el-form-item label="日期区间" prop="dateRange">
                            <el-date-picker v-model="jobForm.dateRange" type="daterange" align="right" unlink-panels
                                            range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"
                                            value-format="yyyy-MM-dd"
                                            style="width: 500px">
                            </el-date-picker>
                          </el-form-item>
                        </el-col>
                        <el-col :span="9" class="data_from_el-col">
                          <div class="hex-form-inf">
                            <div class="hex-form-inf-content">
                              作业的有效期限。
                            </div>
                            <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                          </div>
                        </el-col>
                      </el-row>
                    </el-collapse-transition>
                    <el-row>
                      <el-col :span="15">
                        <el-form-item label="指定节点名称" prop="appointAgentCode">
                          <el-select v-model="jobForm.appointAgentCode" filterable clearable placeholder="请选择"
                                     style="width: 500px">
                            <el-option v-for="item in agentCodeOption" :key="item.agentCode" :label="item.agentName"
                                       :value="item.agentCode">
                            </el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="9" class="data_from_el-col">
                        <div class="hex-form-inf">
                          <div class="hex-form-inf-content">
                            指定作业在哪个节点服务器上执行
                          </div>
                          <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                        </div>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col :span="15">
                        <el-form-item label="作业状态" prop="jobStatus">
                          <el-select v-model="jobForm.jobStatus" filterable style="width: 500px">
                            <el-option v-for="item in this.dict.job_def_status" :key="item.value" :label="item.label"
                                       :value="item.value">
                            </el-option>
                          </el-select>
                        </el-form-item>
                      </el-col>
                      <el-col :span="9" class="data_from_el-col">
                        <div class="hex-form-inf">
                          <div class="hex-form-inf-content">
                            状态（未发布 启用 停用）
                          </div>
                          <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                        </div>
                      </el-col>
                    </el-row>
                    <el-row>
                      <el-col :span="15">
                        <el-form-item label="描述" prop="jobDesc">
                          <el-input type="textarea" :rows="2" placeholder="请输入内容" maxlength="60" show-word-limit
                                    v-model="jobForm.jobDesc" style="width: 500px">
                          </el-input>
                        </el-form-item>
                      </el-col>
                      <el-col :span="9" class="data_from_el-col">
                        <div class="hex-form-inf">
                          <div class="hex-form-inf-content">
                            作业的描述，不可超过60个字。
                          </div>
                          <i class="el-icon-info hex-form-inf-icon" @click="onOperInf($event)" data-status="off"></i>
                        </div>
                      </el-col>
                    </el-row>
                    <div class="form-operator-button" v-if="checkPermission(['appJobDef:edit'])">
                      <el-button type="primary" @click.native="toSubmit" style="margin-right: 100px">保存</el-button>
                    </div>
                  </div>
                </el-col>
              </el-form>
            </el-tab-pane>
            <el-tab-pane label="任务依赖图" name="third">
              <taskDepend :jobCode="jobCode" :bizDate="bizDate" :type="dependTaskType" ref="taskDepend"/>
            </el-tab-pane>
            <el-tab-pane label="任务执行统计" name="four">
              <cyclejobDefEchars :jobCode="jobCode"/>
            </el-tab-pane>
          </el-tabs>
        </div>
      </el-card>
    </div>

    <el-drawer :visible.sync="drawer" :direction="direction" :before-close="handleClose" size="80%">
      <jobDependDetail ref="jobDependDetail" v-bind:jobDependData="jobDependData" v-bind:data="jobData"
                       v-bind:query="jobQuery"
                       v-bind:total="jobTotal" v-on:message="showMessage" v-bind:radio="radio"
                       v-bind:jobNameAndJobCode="jobNameAndJobCode"
                       v-bind:page="jobPage"/>
    </el-drawer>
    <el-drawer :visible.sync="taskDrawer" :direction="direction" :before-close="handleClose" size="80%">
      <taskDependDetail ref="taskDependDetail" v-bind:taskDependData="taskDependData" v-bind:data="taskData"
                        v-bind:query="taskQuery" v-bind:total="taskTotal" v-bind:page="taskPage" v-bind:radio="radio"
                        v-bind:taskNameAndTaskCode="taskNameAndTaskCode" v-on:taskmessage="showTaskMessage"/>
    </el-drawer>

    <!-- 作业详情 end -->
    <!-- 批量修改任务信息 start -->
    <el-dialog title="批量修改任务信息" :visible.sync="dialogVisible" width="400px" :before-close="dialogClose">
      <el-form ref="updateForm" :inline="true" :model="updateForm" size="small" label-width="120px">
        <el-row v-if="updateForm.type=='isOrder'">
          <el-form-item label="是否顺序执行">
            <el-switch v-model="updateForm.isOrder" active-value="1" inactive-value="2"/>
          </el-form-item>
        </el-row>
        <el-row v-if="updateForm.type=='resNum'">
          <el-form-item label="资源数">
            <el-input-number v-model="updateForm.resNum" :min="1" :max="1000"/>
          </el-form-item>
        </el-row>
        <el-row v-if="updateForm.type=='priorityLevel'">
          <el-form-item label="优先级">
            <el-select v-model="updateForm.priorityLevel" placeholder="请选择">
              <el-option v-for="item in levelData" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
        </el-row>
        <el-row v-if="updateForm.type=='allowErrCount'">
          <el-form-item label="允许错误次数">
            <el-input-number v-model="updateForm.allowErrCount" :min="0" :max="100"/>
          </el-form-item>
        </el-row>
        <el-row v-if="updateForm.type=='errDifferDuration'">
          <el-form-item label="出错间隔时长(秒)">
            <el-input-number v-model="updateForm.errDifferDuration" :min="0"/>
          </el-form-item>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button icon="el-icon-document-delete" @click="dialogClose">取消</el-button>
        <el-button icon="el-icon-document-add" type="primary" @click="updateFormSubmit">保存</el-button>
      </div>
    </el-dialog>
    <!-- 批量修改任务信息 end -->
    <div class="dashboard-editor-container" v-if="crud.optPageShow.excelPage">
      <el-card class="box-card" style="padding-bottom: 30px">
        <div slot="header" class="clearfix">
          <div class="el-page-header">
            <div class="el-page-header__left" @click="crud.goBack">
              <i class="el-icon-back"></i>
              <div class="el-page-header__title">返回</div>
            </div>
            <div class="el-page-header__content" style="font-size: 15px;">导入数据</div>
          </div>
        </div>
        <div class="dataFrom" style="width: 400px;border-right: 1px solid #EBEEF5;display: inline-block">
          <el-row>
            <div style="display: inline-block">批次号:</div>
            <div style="display: inline-block;padding-left: 10px">
              <el-input placeholder="请输入批次号" v-model="uploadForm.batchTag" style="width: 310px"/>
            </div>
          </el-row>
          <el-row style="margin-top: 20px;">
            <el-upload ref="upload" action="" class="upload-demo" drag :headers="httpHeaders" :data="uploadForm"
                       :auto-upload="false" multiple :limit="1" :accept="acceptFileType"
                       :on-change="handleUploadJobChange"
                       :on-exceed="handleJobExceed">
              <i class="el-icon-upload"></i>
              <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
            </el-upload>
          </el-row>
          <el-row style="margin-top: 10px">
            <p>备注：</p>
            <p>1、只支持上传.xls、.xlsx文件，文件大小不超过1MB</p>
            <p>2、只支持单文件上传</p>
            <p>3、导入数据只获取文件中第一个sheet内数据</p>
            <p>4、上传文件数据列数与字段必须按文档模板填写</p>
            <p>5、非必填项如果未按字段规则填写则系统取默认值</p>
          </el-row>
          <el-row style="margin-top: 10px;text-align: right;margin-right: 40px;">
            <el-button type="warning"><a href="./static/down_cycle_job_def_templates.xlsx" download="周期作业定义模板">模板下载</a>
            </el-button>
            <el-button type="primary" @click="handlerJobEventByOk">确定上传</el-button>
          </el-row>
        </div>
        <div style="display: inline-block;width: 666px;position: absolute;padding: 0px 30px">
          <el-input type="textarea" placeholder="导入失败数据" v-model="uploadErrorData" :rows="10"/>
        </div>
      </el-card>
    </div>
  </div>
</template>

<script>
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import {mapGetters} from 'vuex'
import CRUD, {presenter, header, form, crud} from '@crud/crud'
import crudOperation from '@crud/extend/cycleTask/cycleJobDef/app/CRUD.operation'
import jobDef from '@/api/cycleJob/job_def'
import taskDef from '@/api/cycleJob/task'
import ElRow from "element-ui/packages/row/src/row";
import Dict from "../../../system/dict";
import api from '@/api/app/appInf'
import taskDepend from "../../components/taskDepend";
import cyclejobDefEchars from '../../components/cyclejobDefEchars'
import jobDependDetail from './jobDependDetail'
import taskDependDetail from './taskDependDetail'
import labelInfoApi from '@/api/label/labelInfo'
import checkPermission from '@/utils/permission' // 权限判断函数


// crud交由presenter持有
const queryList = [
  {
    'cloumValue': 'jobCode',
    'cloumName': '作业编码'
  },
  {
    'cloumValue': 'jobName',
    'cloumName': '作业名称'
  },
  {
    'cloumValue': 'labelName',
    'cloumName': '标签名称'
  },
  {
    'cloumValue': 'batchTag',
    'cloumName': '批次标签'
  }
]
const defaultCrud = CRUD({
  title: '周期作业定义',
  url: 'api/jobDef',
  queryList: queryList,
  crudMethod: {
    ...jobDef
  }
})
const defaultForm = {
  pkId: null,
  jobCode: null,
  jobName: null,
  jobDesc: null,
  jobStatus: null,
  jobPeriod: 'D',
  sortNo: '1',
  offsetHour: null,
  dateExpression: null,
  isValidDate: 2,
  jobStDate: null,
  jobEndDate: null,
  appCode: null,
  appointAgentCode: null,
  dependJobCodeList: null,
  isWorkRun: '0',
  isSingleJob: '0',
  labelCodeList: []
}
export default {
  name: 'appJobDef',
  components: {
    ElRow,
    Dict,
    taskDepend,
    crudOperation,
    jobDependDetail,
    taskDependDetail,
    cyclejobDefEchars
  },
  mixins: [presenter(defaultCrud), header(), form(defaultForm), crud()],
  dicts: ['job_def_status', 'cycle_job_period', 'priority_level', 'job_sortNo', 'task_resNum'],
  directives: {
    "el-select-loadmore": {
      bind(el, binding) {
        // 获取element-ui定义好的scroll盒子
        const SELECTWRAP_DOM = el.querySelector(
          '.el-select-dropdown .el-select-dropdown__wrap'
        )
        SELECTWRAP_DOM.addEventListener('scroll', function () {
          /**
           * scrollHeight 获取元素内容高度(只读)
           * scrollTop 获取或者设置元素的偏移值,常用于, 计算滚动条的位置, 当一个元素的容器没有产生垂直方向的滚动条, 那它的scrollTop的值默认为0.
           * clientHeight 读取元素的可见高度(只读)
           * 如果元素滚动到底, 下面等式返回true, 没有则返回false:
           * ele.scrollHeight - ele.scrollTop === ele.clientHeight;
           */
          const condition =
            this.scrollHeight - this.scrollTop <= this.clientHeight
          if (condition) {
            binding.value()
          }
        })
      }
    }
  },
  data() {
    var validateCode = (rule, value, callback) => {
      if (this.crud.form.pkId) {
        callback();
      }
      var util = {
        isFigure: function (e) {
          return /^[0-9A-Z_|()=>.-]+$/.test(e);
        }
      }
      if (value == null) {
        value = '';
      }
      let isCorrect = true;
      if (!util.isFigure(value))
        isCorrect = false;
      if (rule.field === 'jobCode') {
        if (value.split(" ").join("").length == 0) {
          callback(new Error("作业编码不能为空字符串"));
        } else if (isCorrect == false) {
          callback(new Error("只能输入大写英文字母、下划线、分隔符或数字及指定符号(=>.-)"));
        } else {
          this.checkAppData(value, rule.field);
          setTimeout(() => {
            if (this.validCodeStatus) {
              callback();
            } else {
              if (this.showType == 'task' && this.crud.optPageShow.excelPage == false) {
                callback();
              } else {
                callback(new Error("重复的作业编码"));
              }
            }
          }, 1000);
        }
      } else if (rule.field === 'jobName') {
        var util = {
          isFigure: function (e) {
            return /^[a-zA-Z0-9_\u4e00-\u9fa5-()=>._ ]+$/.test(e);
          }
        }
        let isCorrect = true;
        if (!util.isFigure(value))
          isCorrect = false;
        if (value.split(" ").join("").length == 0) {
          callback(new Error("作业名称不能为空字符串"));
        } else if (isCorrect == false) {
          callback(new Error("不能输入特殊字符"));
        } else {
          this.checkAppData(value, rule.field);
          setTimeout(() => {
            if (this.validNameStatus) {
              callback();
            } else {
              callback(new Error("重复的作业名称"));
            }
          }, 1000);
        }
      }
    };
    var validateTaskCode = (rule, value, callback) => {
      var util = {
        isFigure: function (e) {
          return /^[0-9A-Z_|()=>.-]+$/.test(e);
        }
      }
      if (value == null) {
        value = '';
      }
      let isCorrect = true;
      if (!util.isFigure(value))
        isCorrect = false;
      if (rule.field === 'taskCode') {
        if (value.split(" ").join("").length == 0) {
          callback(new Error("任务编码不能为空字符串！"));
        } else if (isCorrect == false) {
          callback(new Error("只能输入大写英文字母、下划线、分隔符或数字及指定符号(=>.-)"));
        } else {
          this.checkTaskData(value, rule.field);
          setTimeout(() => {
            if (this.validCodeStatus) {
              callback();
            } else {
              callback(new Error("重复的任务编码"));
            }
          }, 1000);
        }
      } else if (rule.field === 'taskName') {
        var util = {
          isFigure: function (e) {
            return /^[a-zA-Z0-9_\u4e00-\u9fa5-()=>._ ]+$/.test(e);
          }
        }
        let isCorrect = true;
        if (!util.isFigure(value))
          isCorrect = false;
        if (value.split(" ").join("").length == 0) {
          callback(new Error("任务名称不能为空字符串"));
        } else if (isCorrect == false) {
          callback(new Error("不能输入特殊字符"));
        } else {
          callback();
        }
      } else if (rule.field === 'shellPath') {
        if (value.split(" ").join("").length == 0) {
          callback(new Error("脚本路径不能为空字符串！"));
        } else {
          callback();
        }
      }
    };
    var validateDateExpression = (rule, value, callback) => {
      if (this.crud.form.jobPeriod == 'O' && this.crud.form.isSingleJob != 1) {
        let value = this.crud.form.dateExpression;
        if (value == '' || value == undefined || value == null) {
          callback(new Error('日期表达式不能为空！'));
        }
        const FloatRegex = /^[*0-9,-]* [*0-9,-]* [*0-9,-]*$/;
        if (!FloatRegex.test(value)) {
          callback(new Error('自定义的日期表达式格式不正确!，说明* 3,9-12 1-5,30（年 月 日）'));
        } else {
          callback();
        }
      } else if (this.jobForm.jobPeriod == 'O' && this.jobForm.isSingleJob != 1) {
        let value = this.jobForm.dateExpression;
        if (value == '' || value == undefined || value == null) {
          callback(new Error('日期表达式不能为空！'));
        }
        const FloatRegex = /^[*0-9,-]* [*0-9,-]* [*0-9,-]*$/;
        if (!FloatRegex.test(value)) {
          callback(new Error('自定义的日期表达式格式不正确!，说明* 3,9-12 1-5,30（年 月 日）'));
        } else {
          callback();
        }
      } else if (this.jobForm.isSingleJob == 1) {
        let value = this.jobForm.dateExpression;
        if (value == '' || value == undefined || value == null) {
          callback(new Error('日期表达式不能为空！'));
        } else {
          callback();
        }
      } else if (this.crud.form.isSingleJob == 1) {
        let value = this.crud.form.dateExpression;
        if (value == '' || value == undefined || value == null) {
          callback(new Error('日期表达式不能为空！'));
        } else {
          callback();
        }
      } else {
        callback();
      }
    }
    return {
      labelList: [],
      labelList1: [],
      bizDatePickerOptions: {
        disabledDate(time) {
          return time.getTime() < (Date.now() - 1000 * 60 * 60 * 24);
        }
      },
      levelData: [
        {
          value: '1',
          label: '1'
        }, {
          value: '2',
          label: '2'
        }, {
          value: '3',
          label: '3'
        }, {
          value: '4',
          label: '4'
        }, {
          value: '5',
          label: '5'
        }, {
          value: '6',
          label: '6'
        }, {
          value: '7',
          label: '7'
        }, {
          value: '8',
          label: '8'
        }, {
          value: '9',
          label: '9'
        }, {
          value: '10',
          label: '10'
        }, {
          value: '11',
          label: '11'
        }, {
          value: '12',
          label: '12'
        }, {
          value: '13',
          label: '13'
        }, {
          value: '14',
          label: '14'
        }, {
          value: '15',
          label: '15'
        }],
      taskDependData: [],
      taskDependObject: [],
      jobDependData: [],
      jobData: [],
      jobQuery: [],
      taskQuery: [],
      taskData: [],
      taskTotal: 0,
      taskPage: 0,
      jobTotal: 0,
      jobPage: 0,
      radio: "1",
      jobNameAndJobCode: "",
      taskNameAndTaskCode: "",
      jobDependObject: [],
      taskDependList: [],
      jobDependList: [],
      drawer: false,
      taskDrawer: false,
      direction: 'rtl',
      loadTaskStatus: false,
      loadStatus: false,
      menus: [],
      jobCode: null,
      showType: 'job',
      dependTaskType: 'taskDef',
      bizDate: null,
      active: 0,
      activeName: 'first',
      taskForm: {
        extParam: '',
        pkId: null,
        jobCode: null,
        taskCode: '',
        taskName: '',
        shellPath: '',
        shellParam: '',
        priorityLevel: '',
        allowErrCount: 0,
        isEndTask: '2',
        isOrder: '1',
        resNum: '5',
        planExecDuration: 0,
        overPlanDuration: 0,
        errDifferDuration: 0,
        appointAgentCode: null,
        dependJobCodeList: [],
        dependTaskCodeList: []
      },
      defaultTaskForm: {
        extParam: '',
        pkId: null,
        jobCode: null,
        taskCode: '',
        taskName: '',
        shellPath: '',
        shellParam: '',
        priorityLevel: '',
        allowErrCount: 0,
        isEndTask: '2',
        isOrder: '1',
        resNum: '5',
        planExecDuration: 0,
        overPlanDuration: 0,
        errDifferDuration: 0,
        appointAgentCode: null,
        dependJobCodeList: [],
        dependTaskCodeList: []
      },
      updateForm: {
        pkIds: [],
        type: null,
        isOrder: '1',
        resNum: 1,
        priorityLevel: '1',
        allowErrCount: 0,
        errDifferDuration: 0
      },
      updateFormDefault: {
        pkIds: [],
        type: null,
        isOrder: '1',
        resNum: 1,
        priorityLevel: '1',
        allowErrCount: 0,
        errDifferDuration: 0
      },
      dialogVisible: false,
      rules: {
        dateRange: [
          {required: true, message: '请选择日期区间', trigger: 'change'}
        ],
        offsetHour: [
          {required: true, message: '请输入偏移小时', trigger: 'change'}
        ],
        jobCode: [{required: true, message: '请输入作业编码', trigger: 'blur'},
          {validator: validateCode, trigger: 'blur'},
        ],
        jobName: [{required: true, message: '请输入作业名称', trigger: 'blur'},
          {validator: validateCode, trigger: 'blur'},
        ],
        jobPeriod: [
          {required: true, message: '请选择频率', trigger: 'change'}
        ],
        dateExpression: [
          {required: true, validator: validateDateExpression, trigger: 'blur'}
        ],
        jobDesc: [
          {min: 0, max: 60, message: '长度不可超过60个字符', trigger: 'blur'}
        ]
      },
      taskRules: {
        taskCode: [
          {required: true, message: '请输入任务编码', trigger: 'blur'},
          {validator: validateTaskCode, trigger: 'blur'}
        ],
        taskName: [
          {required: true, message: '请输入任务名称', trigger: 'blur'},
          {validator: validateTaskCode, trigger: 'blur'}
        ],
        shellPath: [
          {required: true, message: '请输入脚本路径', trigger: 'blur'},
          {validator: validateTaskCode, trigger: 'blur'}
        ],
      },
      permission: {
        add: ['appJobDef:add'],
        edit: ['appJobDef:edit'],
        del: ['appJobDef:del'],
        export: ['appJobDef:export'],
        import: ['appJobDef:import']
      },
      agentCodeOption: [],
      jobList: [],
      taskList: [],
      taskDataList: [],
      taskName: '',
      jobForm: {},
      flag: false,
      cacheObj: {
        jobCode: ''
      },
      graphForm: {
        id: '',
        name: ''
      },
      showDetail: false,
      taskColumn: {},
      taskCols: this.obColumns(),
      fileList: [],
      uploadLoading: false,
      acceptFileType: '.xls,.xlsx',
      uploadUrl: '/api/jobDef/upload',
      httpHeaders: {
        'Authorization': ''
      },
      uploadErrorData: null,
      uploadForm: {
        batchTag: null
      },
      downLoadLoading: '',
      formData: {
        pageIndex: 0,
        pageSize: 20,
      },
      formTaskData: {
        pageIndex: 0,
        pageSize: 20,
      },
      beforeQueryData: '',
      beforeQueryTaskData: '',
      jobDefStatusDict: [],
      jobDefDict: [],
      jobPeriodDict: [],
      jobPeriodStatusDict: [],
      moreQueryList: [
        {
          cloumLable: 'jobCodeFuzzy',
          name: '作业编码',
          type: 'textarea',
          placeholder: '请输入作业编码,支持单个模糊查询和批量精确查询使用逗号分割',
          defaultValue: null
        },
        {
          cloumLable: 'jobNameFuzzy',
          name: '作业名称',
          type: 'textarea',
          placeholder: '请输入作业名称,支持单个模糊查询和批量精确查询使用逗号分割',
          defaultValue: null
        },
        {
          cloumLable: 'labelName',
          name: '标签名称',
          type: 'input',
          placeholder: '请输入标签名称',
          defaultValue: null
        },
        {
          cloumLable: 'batchTag',
          name: '批次标签',
          type: 'input',
          placeholder: '请输入批次标签',
          defaultValue: null
        },
        {
          cloumLable: 'jobStatus',
          name: '作业状态',
          type: 'radio',
          placeholder: '',
          defaultValue: null,
          radioList: [
            {
              label: '',
              value: '全部'
            },
            {
              label: '0',
              value: '未发布'
            },
            {
              label: '1',
              value: '启用'
            },
            {
              label: '2',
              value: '停用'
            }
          ]
        }
      ]
    }
  },
  created() {
    this.getList()
    this.crud.optPageShow.listPage = true;
    this.crud.optPageShow.addPage = false;
    this.crud.optPageShow.excelPage = false;
    this.httpHeaders.Authorization = this.token;
    this.jobDefDict = this.dict.job_def_status
    this.jobPeriodDict = this.dict.cycle_job_period
  },
  watch: {
    'form.labelCode'() {
      this.form.labelCode.forEach((res) => {
        this.labelList.forEach((res1) => {
          if (res.labelLevel == res1.labelLevel) {
            //res1.disabled=true
          }
        })
      })
    },
    'jobForm.labelCode'() {
      this.jobForm.labelCode.forEach((res) => {
        this.labelList1.forEach((res1) => {
          if (res.labelLevel == res1.labelLevel) {
            //res1.disabled=true
          }
        })
      })
    },
    'activeName': function (val) { //监听切换状态-计划单
      if ("third" == val) {
        this.initAgentCodes();
        this.queryTaskList(this.jobCode);
      }
    },
    jobDefDict() {
      this.$nextTick(() => {
        this.jobDefDict.forEach(item => {
          var obj = {
            text: item.label,
            value: item.value
          }
          this.jobDefStatusDict.push(obj)
        })
      })
    },
    jobPeriodDict() {
      this.$nextTick(() => {
        this.jobPeriodDict.forEach(item => {
          var obj = {
            text: item.label,
            value: item.value
          }
          this.jobPeriodStatusDict.push(obj)
        })
      })
    },
    'crud.optPageShow.addPage'() {
      if (this.crud.optPageShow.addPage) {
        this.form.labelCode = [];
        this.jobForm = {};
      }
    }
  },
  computed: {
    ...mapGetters([
      'token'
    ])
  },
  methods: {
    checkPermission,
    aaa(val) {
      this.labelList.forEach((res) => {
        if (res.labelLevel == val.labelLevel) {
          res.disabled = false
        }
      })
    },
    bbb(val) {
      this.labelList1.forEach((res) => {
        if (res.labelLevel == val.labelLevel) {
          res.disabled = false
        }
      })
    },
    getList() {
      labelInfoApi.queryList().then(res => {
        this.labelList = JSON.parse(JSON.stringify(res))
        this.labelList1 = JSON.parse(JSON.stringify(res))
      })
    },
    handleClick(tab, event) {
      // if (tab.name == "third") {
      //   this.$refs.taskDepend.setGraphData()
      // }
    },
    formatterjobName(val) {
      return val.jobName + "(" + val.jobCode + ")"
    },
    handleClose(done) {
      this.$confirm('还没确认选择，确认关闭？')
        .then(_ => {
          done();
        })
        .catch(_ => {
        });
    },
    moreDepend() {
      jobDef.getJobList().then(res => {
        this.jobData = res.content
        this.jobTotal = res.total
      })
      this.jobPushList()
      this.drawer = true;
    },
    jobPushList() {
      this.jobDependData = [];
      this.taskForm.dependJobCodeList.forEach((item, i) => {
        let jobCode = "";
        this.jobDependObject.forEach((obj, i) => {
          if (obj.jobName === item) {
            jobCode = obj.jobCode;
          }
        })
        if (jobCode === "") {
          this.jobDependList.forEach((item, k) => {
            if (k === i) {
              jobCode = item;
            }
          })
        }
        this.jobDependData.push({
          "jobName": item,
          "jobCode": jobCode
        })
      })
    },
    moreTaskDepend() {
      taskDef.getTask().then(res => {
        this.taskData = res.content
        this.taskTotal = res.total
      })
      this.taskPushList()
      this.taskDrawer = true;
    },
    taskPushList() {
      this.taskDependData = [];
      this.taskForm.dependTaskCodeList.forEach((item, i) => {
        var taskCode = "";
        this.taskDependObject.forEach((obj, i) => {
          if (obj.taskName === item) {
            taskCode = obj.taskCode;
          }
        })
        if (taskCode === "") {
          this.taskDependList.forEach((item, k) => {
            if (k === i) {
              taskCode = item;
            }
          })
        }

        this.taskDependData.push({
          "taskName": item,
          "taskCode": taskCode
        })
      })
    },
    showMessage: function (data) {
      this.taskForm.dependJobCodeList = [];
      this.jobDependObject = [];
      var dependJobNameStr = '';
      data.forEach((item, i) => {
        this.jobDependObject.push(item)
        if (!this.isInArray(this.taskForm.dependJobCodeList, item.jobName)) {
          if (data.length - 1 == i) {
            dependJobNameStr = dependJobNameStr + item.jobName;
          } else {
            dependJobNameStr = dependJobNameStr + item.jobName + ",";
          }
        }
      })
      this.taskForm.dependJobCodeList = dependJobNameStr.split(",");
      this.drawer = false;
    },
    showTaskMessage: function (data) {
      this.taskForm.dependTaskCodeList = [];
      this.taskDependObject = [];
      this.taskDrawer = false;
      var dependTaskNameStr = '';
      data.forEach((item, i) => {
        this.taskDependObject.push(item)
        if (!this.isInArray(this.taskForm.dependTaskCodeList, item.taskName)) {
          if (data.length - 1 == i) {
            dependTaskNameStr = dependTaskNameStr + item.taskName;
          } else {
            dependTaskNameStr = dependTaskNameStr + item.taskName + ",";
          }
        }
      })
      this.taskForm.dependTaskCodeList = dependTaskNameStr.split(",");
    },
    isInArray(arr, value) {
      for (var i = 0; i < arr.length; i++) {
        if (value === arr[i]) {
          return true;
        }
      }
      return false;
    },
    loadmore() {
      this.formData.pageIndex++;
      this.getJobListByCurrentApp(this.formData);
    },
    loadmoreTask() {
      this.formTaskData.pageIndex++;
      this.getDependTaskByCurrentApp(this.formTaskData)
    },
    //限制输入特殊字符
    btKeyUp(e) {
      e.target.value = e.target.value.replace(
        /[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~！@#￥%……&*（）——\-+={}|《》？：“”【】、；‘’，。、]/g, "");
    },
    // 新增前
    [CRUD.HOOK.beforeToAdd](crud) {
      this.active = 0;
      //初始化节点编码
      this.initAgentCodes();
    },
    // 编辑前
    [CRUD.HOOK.beforeToEdit](crud) {
      this.initAgentCodes();
    },
    // 判断应用编码或应用名称是否重复
    checkAppData(value, field) {
      let param = {};
      //调用后台接口判断是否重复
      param[field] = value;
      if (this.crud.form.pkId != null) {
        param["pkId"] = this.crud.form.pkId;
      }
      if (this.jobForm.pkId != null) {
        param["pkId"] = this.jobForm.pkId;
      }
      jobDef.checkAppData(param).then(res => {
        if ('jobCode' === field) {
          this.validCodeStatus = res;
        } else {
          this.validNameStatus = res;
        }
      })
    },

    // 判断任务编码或任务名称是否重复
    checkTaskData(value, field) {
      let param = {};
      //调用后台接口判断是否重复
      param[field] = value;
      if (this.crud.form.pkId != null) {
        param["pkId"] = this.crud.form.pkId;
      }
      if (this.taskForm.pkId != null) {
        param["pkId"] = this.taskForm.pkId;
      }
      jobDef.validateTaskCode(param).then(res => {
        if ('taskCode' === field) {
          this.validCodeStatus = res;
        } else {
          this.validNameStatus = res;
        }
      })
    },
    jobPeriodFormatter(val) {
      return this.dict.label.cycle_job_period[val]
    },
    jobStatusFormatter(val) {
      return this.dict.label.job_def_status[val.jobStatus]
    },
    jobStatusFormatterType(val) {
      const type = ['primary', 'success', 'info', 'warning', 'danger']
      return type[val]
    },
    // 改变状态
    changeEnabled(data, val) {
      this.$confirm('此操作将 "' + this.dict.label.user_status[val] + '" 【' + data.appName + '】, 是否继续？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        data.enabled = data.enabled
      }).catch(() => {
        data.enabled = !data.enabled
      })
    },
    nextSetp() {
      this.active++;
    },
    lastSetp3() {
      this.active--;
    },
    lastSetp() {
      this.initJobDefList();
      this.initTaskDefList();
      if (this.taskForm.taskCode == null || this.taskForm.taskCode == '') {
        this.taskForm = JSON.parse(JSON.stringify(this.defaultTaskForm));
      }
      this.active--;
    },
    finish() {
      //设置steps为初始状态
      this.active = 0;
      this.crud.goBack();
      this.crud.toQuery();
    },
    initAgentCodes() {
      api.findNodeByCurrentApp()
        .then(res => {
          this.agentCodeOption = res;
        });
    },
    initJobDefList(jobNameOrCode) {
      if (jobNameOrCode != null && jobNameOrCode !== '') {
        if (jobNameOrCode != this.beforeQueryData) {
          this.formData.pageIndex = 0
        }
        this.$set(this.formData, "jobNameOrCode", jobNameOrCode)
        this.loading = true;
        this.getJobListByCurrentApp(this.formData)
        this.beforeQueryData = jobNameOrCode;
      } else {
        this.jobList = [];
      }
    },
    getJobListByCurrentApp(formData) {
      setTimeout(() => {
        this.loading = false;
        jobDef.getJobListByCurrentApp(formData)
          .then(res => {
            this.jobList = res.content;
          });
      }, 200);
    },
    initTaskDefList(taskNameOrCode) {
      this.taskList = [];
      if (taskNameOrCode != null && taskNameOrCode !== '') {
        if (taskNameOrCode != this.beforeQueryTaskData) {
          this.formTaskData.pageIndex = 0
        }
        this.$set(this.formTaskData, "taskNameOrCode", taskNameOrCode)
        this.loading = true;
        this.getDependTaskByCurrentApp(this.formTaskData)
        this.beforeQueryTaskData = taskNameOrCode;
      } else {
        this.taskList = [];
      }
    },
    getDependTaskByCurrentApp(formTaskData) {
      setTimeout(() => {
        this.loading = false;
        taskDef.getDependTaskByCurrentApp(formTaskData)
          .then(res => {
            this.taskList = res.content;
          });
      }, 200);
    },
    toCrud(crud) {
      this.$refs['form'].validate(valid => {
        if (!valid) {
          return
        }
        jobDef.edit(crud.form).then(res => {
          crud.status.edit = CRUD.STATUS.NORMAL;
          crud.getDataStatus(crud.form.id).edit = CRUD.STATUS.NORMAL;
          this.$notify({
            title: '修改作业成功',
            type: 'success',
            duration: 1500
          });
          crud.optPageShow.listPage = true;
          crud.optPageShow.addPage = false;
          crud.refresh();
        }).catch(() => {
          crud.status.edit = CRUD.STATUS.PREPARED;
        });

        //this.active++;
      })
    },
    goTaskInfo(row, column, event) {
      this.jobPeriodChange(row.jobPeriod)
      this.showType = 'task';
      this.activeName = 'first';
      this.jobCode = row.jobCode;
      this.doReply();
      this.initAgentCodes();
      this.qryJobDefByJobCode(row.jobCode);
    },
    qryJobDefByJobCode(jobCode) {
      jobDef.qryJobDefByJobCode(jobCode)
        .then(res => {
          res.labelCode = []
          this.jobForm = res;
          this.labelList.forEach((data) => {
            res.labelCodeList.forEach((data1) => {
              if (data.labelCode == data1) {
                this.jobForm.labelCode.push(data)
              }
            })
          })
          this.jobForm.sortNo = this.jobForm.sortNo + '';
          this.taskForm.priorityLevel = this.jobForm.sortNo
          if (this.jobForm.jobStDate != null && this.jobForm.jobStDate != '' && this.jobForm.jobEndDate != null &&
            this.jobForm.jobEndDate != '') {
            this.$set(this.jobForm, 'dateRange', [this.jobForm.jobStDate, this.jobForm.jobEndDate]);
          }
        });
    },
    getTaskColumns() {
      const columns = {};
      this.$refs.taskTable.columns.forEach(e => {
        if (!e.property || e.type !== "default") {
          return;
        }
        columns[e.property] = {
          label: e.label,
          visible: true
        };
      });
      this.taskCols = this.obColumns(columns);
      this.taskColumn = columns;
    },
    obColumns(columns) {
      return {
        visible(col) {
          return !columns || !columns[col] ? true : columns[col].visible;
        }
      };
    },
    goBack() {
      this.showType = 'job';
      this.showDetail = false;
      this.crud.refresh();
      this.taskForm = JSON.parse(JSON.stringify(this.defaultTaskForm));
    },
    toAddTask(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          let param = this.taskForm;
          param.jobCode = this.jobForm.jobCode
          jobDef.toAddTask(param).then(res => {
            if (res && true === res) {
              this.$notify({
                title: '新增任务成功',
                type: 'success',
                duration: 1500
              })
              this.taskForm = JSON.parse(JSON.stringify(this.defaultTaskForm));
              this.goBack();
            }
          })
        } else {
          return false;
        }
      });
    },
    //根据作业编号 查询任务列表
    queryTaskList(param) {
      jobDef.queryTaskList(param).then(res => {
        if (res) {
          this.taskDataList = res;
          this.getTaskColumns();
        }
      })
    },
    propToUpadate(param) {
      jobDef.propToUpadate(param).then(res => {
        if (res && true === res) {
          //更新成功
          this.$notify({
            title: '更新任务成功',
            type: 'success',
            duration: 1500
          })
          this.queryTaskList(this.jobForm.jobCode);
        }
      });
    },
    taskdetail(row, column, event) {
      this.flag = true;
      this.taskForm.pkId = row.pkId
      this.taskForm.taskCode = row.taskCode
      this.taskForm.taskName = row.taskName
      this.taskForm.shellPath = row.shellPath
      this.taskForm.extParam = row.extParam
      this.taskForm.appointAgentCode = row.appointAgentCode
      this.taskForm.priorityLevel = row.priorityLevel
      this.taskForm.resNum = row.resNum
      this.taskForm.allowErrCount = row.allowErrCount
      this.taskForm.isEndTask = row.isEndTask
      this.taskForm.isOrder = row.isOrder
      this.taskForm.planExecDuration = row.planExecDuration
      this.taskForm.overPlanDuration = row.overPlanDuration
      this.taskForm.errDifferDuration = row.errDifferDuration
      if (row.dependTaskName != null && row.dependTaskName !== '') {
        this.taskForm.dependTaskCodeList = row.dependTaskName.split(",");
        this.taskDependList = [];
        this.taskDependList = row.dependTask.split(",");
      } else {
        this.taskForm.dependTaskCodeList = [];
      }
      if (row.dependJobName != null && row.dependJobName !== '') {
        this.taskForm.dependJobCodeList = row.dependJobName.split(",");
        this.jobDependList = row.dependJob.split(",");
      } else {
        this.taskForm.dependJobCodeList = [];
      }
      this.taskPushList()
      this.jobPushList()
    },
    refreshTaskList() {
      this.queryTaskList(this.crud.form.jobCode);
    },
    doReply() {
      this.queryTaskList(this.jobCode);
    },
    editTask(row) {
      this.taskForm.pkId = row.pkId
      this.taskForm.taskCode = row.taskCode
      this.taskForm.taskName = row.taskName
      this.taskForm.shellPath = row.shellPath
      this.taskForm.extParam = row.extParam
      this.taskForm.appointAgentCode = row.appointAgentCode
      this.taskForm.priorityLevel = row.priorityLevel
      this.taskForm.resNum = row.resNum
      this.taskForm.allowErrCount = row.allowErrCount
      this.taskForm.isEndTask = row.isEndTask
      this.taskForm.isOrder = row.isOrder
      this.taskForm.planExecDuration = row.planExecDuration
      this.taskForm.overPlanDuration = row.overPlanDuration
      this.taskForm.errDifferDuration = row.errDifferDuration
      if (row.dependTaskName != null && row.dependTaskName !== '') {
        this.taskForm.dependTaskCodeList = row.dependTaskName.split(",");
        this.taskDependList = row.dependTask.split(",");
      } else {
        this.taskForm.dependTaskCodeList = [];
      }
      if (row.dependJobName != null && row.dependJobName !== '') {
        this.taskForm.dependJobCodeList = row.dependJobName.split(",");
        this.jobDependList = [];
        this.jobDependList = row.dependJob.split(",");
      } else {
        this.taskForm.dependJobCodeList = [];
      }

      this.initJobDefList();
      this.initTaskDefList();
      this.active--;
    },
    deleteTask(param) {
      this.$confirm(`确定删除该条记录吗?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.taskForm.taskCode = null
        let p = [param]
        jobDef.doDeleteByPkId(p).then(res => {
          if (res && true === res) {
            this.$notify({
              title: '删除成功',
              type: 'success',
              duration: 1500
            })
            this.refreshTaskList()
          }
        })
      }).catch(err => {

      })
    },
    toJobDefAdd() {
      this.showType = 'taskAdd';
    },
    //新增作业下一步
    nextSetp1() {
      this.$refs['form'].validate(valid => {
        if (!valid) {
          return
        }
        this.loadStatus = true;
        let pkId = this.crud.form.pkId;
        if (pkId != null && pkId != '' && pkId != undefined) {
          this.doUpdateJobDef(this.crud.form);
        } else {
          this.doSaveJobDef();
        }
      })
    },
    doSaveJobDef() {
      jobDef.add(this.crud.form).then(res => {
        this.loadStatus = false,
          this.$notify({
            title: '新增作业成功',
            type: 'success',
            duration: 1500
          });
        this.jobCode = this.crud.form.jobCode;
        this.taskForm.appointAgentCode = this.crud.form.appointAgentCode;
        this.defaultTaskForm.appointAgentCode = this.crud.form.appointAgentCode;
        this.taskForm.priorityLevel = this.crud.form.sortNo;
        this.defaultTaskForm.priorityLevel = this.crud.form.sortNo;
        this.crud.form.pkId = res;
        this.initJobDefList();
        this.initTaskDefList();
        this.active++;
      }).catch(() => {
        this.loadStatus = false;
        this.crud.status.add = CRUD.STATUS.PREPARED;
      });
    },
    toSubmit() {
      this.$refs['jobForm'].validate(valid => {
        if (!valid) {
          return
        }
        jobDef.edit(this.jobForm).then(res => {
          this.$notify({
            title: '修改作业成功',
            type: 'success',
            duration: 1500
          });
        }).catch(() => {
          this.$notify({
            title: '修改作业失败',
            type: 'error',
            duration: 1500
          });
        });
      })
    },
    doUpdateJobDef(dataForm) {
      jobDef.edit(dataForm).then(res => {
        this.loadStatus = false;
        this.crud.status.edit = CRUD.STATUS.NORMAL;
        this.jobCode = this.crud.form.jobCode;
        this.taskForm.appointAgentCode = this.crud.form.appointAgentCode;
        this.defaultTaskForm.appointAgentCode = this.crud.form.appointAgentCode;
        this.taskForm.priorityLevel = this.crud.form.sortNo;
        this.defaultTaskForm.priorityLevel = this.crud.form.sortNo;
        this.crud.getDataStatus(this.crud.form.id).edit = CRUD.STATUS.NORMAL;
        this.$notify({
          title: '修改作业成功',
          type: 'success',
          duration: 1500
        });
        this.initJobDefList();
        this.initTaskDefList();
        this.active++;
      }).catch(() => {
        this.crud.status.edit = CRUD.STATUS.PREPARED;
      });
    },
    //新增任务下一步
    nextSetp2(formName) {
      //保存任务 todo
      this.$refs[formName].validate((valid) => {
        if (!valid) {
          return
        }
        this.loadTaskStatus = true;
        this.taskForm.jobCode = this.crud.form.jobCode;
        if (this.taskForm.pkId != null && this.taskForm.pkId != '') {
          this.toUpdateTask();
        } else {
          this.toAddTaskDef();
        }

      });
    },
    toAddTaskDef() {
      this.getDependCode();
      jobDef.toAddTask(this.taskForm).then(res => {
        if (res && true === res) {
          this.loadTaskStatus = false;
          this.$notify({
            title: '新增任务成功',
            type: 'success',
            duration: 1500
          })
          this.taskForm = JSON.parse(JSON.stringify(this.defaultTaskForm));
          this.active++;
          //跳转到任务列表，根据作业编号查询任务列表
          this.queryTaskList(this.crud.form.jobCode);
        }
      })
      this.jobDependObject = [];
      this.taskDependObject = [];
    },
    toUpdateTask() {
      this.getUpDependCode();
      jobDef.propToUpadate(this.taskForm).then(res => {
        this.loadTaskStatus = false;
        this.$notify({
          title: '更新任务成功',
          type: 'success',
          duration: 1500
        })
        this.taskForm = JSON.parse(JSON.stringify(this.defaultTaskForm));
        this.active++;
        //跳转到任务列表，根据作业编号查询任务列表
        this.queryTaskList(this.crud.form.jobCode);
      }).catch(() => {
        this.$notify({
          title: '删除失败！',
          type: 'error',
          duration: 1500
        })
      })
      this.jobDependObject = [];
      this.taskDependObject = [];
    },
    onOperInf: function (e) {
      let status = e.target.getAttribute('data-status');
      let previousNode = e.target.previousElementSibling;
      if ("off" == status) {
        previousNode.setAttribute('class', 'hex-form-inf-content-show');
        e.target.setAttribute('data-status', 'on');
      } else {
        previousNode.setAttribute('class', 'hex-form-inf-content');
        e.target.setAttribute('data-status', 'off');
      }
    },
    onNodeClick(nodeObject) {
      if (nodeObject) {
        this.graphForm.id = nodeObject.id;
        this.graphForm.name = nodeObject.text;
        this.showDetail = true;
      }
    },
    jobPeriodChange(value) {
      // this.form.dateExpression=0;
      //this.$refs['form'].validateField('dateExpression')
      if (this.jobForm.pkId != null) {
        this.jobForm.dateExpression = this.dateExpressionChange(value)
      }
      if (this.crud.optPageShow.addPage) {
        this.crud.form.dateExpression = this.dateExpressionChange(value)
      }
      //优先级改变
      var scope = this.dict.label.job_sortNo[value]
      var scopeSplit = scope.split("-")
      var count = parseInt(scopeSplit[0])
      //默认值
      this.form.sortNo = scopeSplit[0]
      this.jobForm.sortNo = scopeSplit[0]
      this.taskForm.priorityLevel = scopeSplit[0]
      this.levelData = []
      while (count <= parseInt(scopeSplit[1])) {
        var obj = {
          value: count,
          label: count
        }
        this.levelData.push(obj);
        count++
      }
    },
    dateExpressionChange(value) {
      if ("D" == value) {
        return null;
      } else if ("W" == value) {
        return 1;
      } else if ("X" == value) {
        return 1;
      } else if ("M" == value) {
        return 1;
      } else if ("Q" == value) {
        return 1;
      } else if ("Y" == value) {
        return 1;
      } else if ("O" == value) {
        return null;
      } else if ("O" != value && this.jobForm.dateExpression != '' && this.jobForm.dateExpression != null) {
        this.jobForm.dateExpression = '';
      }
    },
    goListBack() {
      this.resetJobForm();
      this.crud.goBack();
      if (this.active > 0) {
        this.crud.refresh();
      }
    },
    resetJobForm() {
      this.taskForm = JSON.parse(JSON.stringify(this.defaultTaskForm));
    },
    saveTaskDef() {
      this.$refs["taskForm"].validate((valid) => {
        if (valid) {
          this.taskForm.jobCode = this.jobCode;
          if (this.taskForm.pkId == null) {
            this.toAddTaskDef2();
          } else {
            this.toUpdateTask2();
          }
        } else {
          return false;
        }
      });
    },
    //依赖显示是名称，需要传编码到后台
    getDependCode() {
      var jobCodeList = [];
      this.jobDependObject.forEach((obj, i) => {
        jobCodeList.push(obj.jobCode)
      })
      this.taskForm.dependJobCodeList = jobCodeList
      var taskCodeList = [];
      this.taskDependObject.forEach((obj, i) => {
        taskCodeList.push(obj.taskCode)
      })
      this.taskForm.dependTaskCodeList = taskCodeList
    },
    //依赖显示是名称，需要传编码到后台
    getUpDependCode() {
      var jobCodeList = [];
      this.jobDependData.forEach((obj, i) => {
        if (this.isInArray(this.taskForm.dependJobCodeList, obj.jobName)) {
          jobCodeList.push(obj.jobCode)
        }
      })
      this.taskForm.dependJobCodeList = jobCodeList
      var taskCodeList = [];
      this.taskDependData.forEach((obj, i) => {
        if (this.isInArray(this.taskForm.dependTaskCodeList, obj.taskName)) {
          taskCodeList.push(obj.taskCode)
        }
      })
      this.taskForm.dependTaskCodeList = taskCodeList
    },
    toAddTaskDef2() {
      if (checkPermission(['appJobDef:add'])) {
        this.getDependCode();
        jobDef.toAddTask(this.taskForm).then(res => {
          if (res && true === res) {
            this.$notify({
              title: '新增任务成功',
              type: 'success',
              duration: 1500
            })
            this.taskForm = JSON.parse(JSON.stringify(this.defaultTaskForm));
            this.queryTaskList(this.jobCode);
          }
        })
        this.jobDependObject = [];
        this.taskDependObject = [];
      } else {
        this.$notify({ title: '您没有新增权限', type: 'warning', duration: 1500 })
      }
    },
    toUpdateTask2() {
      if (checkPermission(['appJobDef:edit'])) {
        this.getUpDependCode();
        jobDef.propToUpadate(this.taskForm).then(res => {
          this.$notify({
            title: '更新任务成功',
            type: 'success',
            duration: 1500
          })
          this.taskForm = JSON.parse(JSON.stringify(this.defaultTaskForm));
          this.queryTaskList(this.jobCode);
        }).catch(() => {
          this.$notify({
            title: '更新失败！',
            type: 'error',
            duration: 1500
          })
        })
        this.jobDependObject = [];
        this.taskDependObject = [];
      }else {
        this.$notify({ title: '您没有修改权限', type: 'warning', duration: 1500 })
      }
    },
    toDeleteTask(datas) {
      this.$confirm(`确认删除选中的${datas.length}条数据?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        jobDef.doDeleteByPkId(datas)
          .then(res => {
            this.$notify({
              title: '删除成功！',
              type: 'success',
              duration: 1500
            })
            this.doReply();
          })
          .catch(() => {
            this.$notify({
              title: '删除失败！',
              type: 'error',
              duration: 1500
            })
          })
      }).catch(() => {
      })
    },
    // 批量更新是否顺序执行
    updateTaskInf(data, type) {
      if (type == 'priorityLevel' && data.length == 1) {
        this.updateForm.priorityLevel = data[0].priorityLevel
      }
      this.updateForm.type = type;
      data.forEach(val => {
        this.updateForm.pkIds.push(val.pkId);
      });
      this.dialogVisible = true;
    },
    //关闭批量更新任务弹窗
    dialogClose() {
      this.dialogVisible = false;
      this.updateForm = JSON.parse(JSON.stringify(this.updateFormDefault));
    },
    // 提交批量更新任务
    updateFormSubmit() {
      taskDef.batchUpdateTaskInf(this.updateForm)
        .then(res => {
          this.$notify({
            title: '更新成功！',
            type: 'success',
            duration: 1500
          })
          this.dialogClose();
          this.doReply();
        })
        .catch(() => {
          this.$notify({
            title: '更新失败！',
            type: 'error',
            duration: 1500
          })
          this.dialogClose();
        })
    },
    [CRUD.HOOK.afterUpload](crud, rsp) {
      if (rsp.status === true) {
        this.$notify.success({
          title: '提示',
          message: '导入成功!'
        });
        this.crud.goBack();
        this.crud.toQuery();
      } else {
        this.uploadErrorData = rsp.message;
        this.$refs['upload'].clearFiles();
        this.$notify.error({
          title: '提示',
          message: '导入失败!'
        });
      }
    },
    handlerJobEventByOk() {
      if (this.fileList.length > 0) {
        this.uploadLoading = true;
        const formData = new FormData();
        const appInfo = JSON.parse(localStorage.getItem('appInfo'))
        formData.append('file', this.fileList[0].raw);
        formData.append("appCode", appInfo.appCode);
        formData.append("batchTag", this.uploadForm.batchTag);
        formData.append("appCode", appInfo.appCode);
        this.crud.doupload(formData);
      } else {
        this.$notify.error({
          title: '错误',
          message: '请选择导入的文件!'
        });
      }
      ;
    },
    handleJobExceed(files, fileList) {
      this.$notify.error({
        title: '提示',
        message: '只支持单个文件上传!'
      });
    },
    handleUploadJobChange(file, fileList) {
      this.fileList = fileList;
      var fileName = file.name.substring(file.name.lastIndexOf('.') + 1);
      if (fileName != 'xlsx' && fileName != 'xls') {
        this.beforUploadJobError("文件类型不是excel文件!");
        this.$refs['upload'].clearFiles();
        return false;
      }
      //读取文件大小
      var fileSize = file.size;
      if (fileSize > 1048576) {
        this.beforUploadJobError("选择的文件大小不能超过1M");
        this.$refs['upload'].clearFiles();
        return false;
      }
      if (this.uploadForm.batchTag == null || this.uploadForm.batchTag == '') {
        this.uploadForm.batchTag = this.$moment(new Date()).utcOffset(480).format("YYYY-MM-DD");
      }
      return true;
    },
    beforUploadJobError(msg) {
      this.$notify.error({
        title: '错误',
        message: msg
      });
    },
    isSingleJobChange() {
      this.form.dateExpression = ''
    },
    editIsSingleJobChange() {
      this.jobForm.dateExpression = ''
    }
  }
}
</script>
